package com.wenli.graduate2022.wenliGreenShop.service.servImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wenli.graduate2022.wenliGreenShop.entity.Category;
import com.wenli.graduate2022.wenliGreenShop.repository.mapper.CategoryMapper;
import com.wenli.graduate2022.wenliGreenShop.service.servDao.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HuangHai
 * @date 2021/10/8 17:58
 */
@Service
public class CategoryServImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;

    @Override

    public List<Category> findAll() {
        return categoryMapper.findAll();
    }

    /**
     * 查询某个页面的数据
     * @param page
     * @return
     */
    @Override
    public IPage<Category> findByPage(Page page) {
        return categoryMapper.findByPage(page);
    }

    @Override
    public Category findById(Integer id) {
        return categoryMapper.findById(id);
    }

    /**
     * 插入
     * @param category
     * @return
     */
    @Override
    public int insert(Category category) {
        return categoryMapper.insert(category);
    }

    @Override //修改
    public int update(Category category) {
        return categoryMapper.update(category);
    }

    @Override  //删除
    public int delete(Integer id) {
        return categoryMapper.delete(id);
    }

    @Override  //模糊查询
    public IPage<Category> findByName(Page page,String name) {
        return categoryMapper.findByName(page,name);
    }
}
